/**
 * 判断某个实例是否属于该类型
 */
class Teacher{
    name:string=''
    school:string=''
    constructor(name:string,school:string){
        this.name=name;
        this.school=school
    }
    introduce():string{
        return `我是${this.school}的${this.name}`
    }
    giveLession(){
        console.log('讲解本章目标');
        console.log('讲解具体内容');
        console.log('安排作业');
    }
}

class SoftWareTeacher extends Teacher{
    giveLession(): void {
        console.log('打开开发环境');
        super.giveLession()        
    }
    writeProgram(){
        console.log('编写程序');
    }
}

class DancerTeacher extends Teacher{
    giveLession(): void {
        console.log('开音乐');
        super.giveLession()
    }
    tiaowu(){
        console.log('跳舞');
    }
}
/*
    使用instanceof可以判断该实例是否属于该类型
    这样可以提高代码健壮性。
*/
class Traing{
    shangke(teahcer:Teacher){
        teahcer.giveLession()
        if(teahcer instanceof SoftWareTeacher){
            teahcer.writeProgram()
        }else if(teahcer instanceof DancerTeacher){
            teahcer.tiaowu()
        }
    }
}

let xhd=new SoftWareTeacher("徐海东","蜗牛学员")
xhd.giveLession()
xhd.writeProgram()
console.log('**********************************');

let jx=new DancerTeacher('金星',"中央舞蹈学院")
jx.giveLession()
jx.tiaowu()

